package MVC.Views;

import MVC.Controller;
import MVC.View;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ApplicationView extends View {

    /* Atributos */
    private JPanel mainPanel;
    private JTextField nomeTextField;
    private JButton conectarButton;
    private JLabel pentagoLabel;
    private JLabel nomeLabel;
    private JTextField servidorTextField;
    private JLabel servidorLabel;

    public ApplicationView() {
        conectarButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                if(!nomeTextField.getText().isEmpty() && !servidorTextField.getText().isEmpty()) {
                    Controller.jogadorController.conectar(nomeTextField.getText(), servidorTextField.getText());
                } else
                    alert("Preencha todos os campos antes de conectar.");
            }
        });

        open();
    }

    /* Métodos */
    public void rendered() {
        frame.setMinimumSize(new Dimension(300, 400));
        show();
    }

    public JPanel mainPanel() {
        return mainPanel;
    }

}
